<@_sysSite id=id>
    <#assign a=object/>
</@_sysSite>
<@_sysSite id=(a.parentId)!parentId><#assign parent=object/></@_sysSite>
<script>
function siteDefaultConfig${id!}(type){
    var directory=$('input[name=directory]',navTab.getCurrentPanel()).val();
    if(directory) {
        directory += '/';
    } else {
        directory = ''
    }
    if('static'==type){
        if(!$('input[name=useStatic]',navTab.getCurrentPanel()).is(":checked")){
            $('input[name=useStatic]',navTab.getCurrentPanel()).click();
        }
        if($('input[name=useSsi]',navTab.getCurrentPanel()).is(":checked")){
            $('input[name=useSsi]',navTab.getCurrentPanel()).click();
        }
        $('input[name=sitePath]',navTab.getCurrentPanel()).val("//"+location.host+"${base}/webfile/"+directory);
        $('input[name=dynamicPath]',navTab.getCurrentPanel()).val("//"+location.host+"${base}/"+directory);
    }else{
        if($('input[name=useStatic]',navTab.getCurrentPanel()).is(":checked")){
            $('input[name=useStatic]',navTab.getCurrentPanel()).click();
        }
        $('input[name=sitePath]',navTab.getCurrentPanel()).val("//"+location.host+"${base}/webfile/"+directory);
        $('input[name=dynamicPath]',navTab.getCurrentPanel()).val("//"+location.host+"${base}/"+directory);
    }
    <#if !a?has_content>
        $('input[name=domain]',navTab.getCurrentPanel()).val(location.hostname);
    </#if>
    $('.info',navTab.getCurrentPanel()).show();
}
</script>
<form method="post" autocomplete="off" action="sysSite/save?callbackType=closeCurrent&navTabId=sysSite/list" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
    <input name="id" type="hidden" value="${id!}" />
    <input type="hidden" name="_csrf" value="<@_csrfToken admin=true/>"/>
    <input type="hidden" name="encoding" value="sha512"/>
    <div class="formBar">
        <ul>
            <li><button type="submit" class="buttonActive" title="ctrl+s"><@t.page 'button.save'/></button></li>
            <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
        </ul>
    </div>
    <div class="pageFormContent" layoutH>
    <#if parent?has_content>
        <dl class="nowrap">
            <dt><@t.page 'site.parent'/>:</dt>
            <dd>
                <input class="disabled" type="text" size="30" value="${(parent.name)!}"/>
                <input name="parentId" type="hidden" value="${(parent.id)!}"/>
                <span class="info"><@t.page 'site.parent.description'/></span>
            </dd>
        </dl>
        <dl class="nowrap">
            <dt><@t.page 'directory'/>:</dt>
            <dd>
                <input name="directory" type="text" maxlength="50" size="30" value="${(a.directory)!}"/>
            </dd>
        </dl>
    </#if>
        <dl>
            <dt><@t.page 'name'/>:</dt>
            <dd>
                <input class="required" name="name" type="text" maxlength="255" size="30" value="${(a.name)!}"/>
                <label><input name="useStatic" type="checkbox"<#if a?has_content&&a.useStatic> checked="checked"</#if>/><@t.page 'site.enable_static'/></label>
                <span class="info hide"><@t.page 'site.config.description'/></span>
            </dd>
        </dl>
        <p>
            <button type="button" class="button" onclick="siteDefaultConfig${id!}('static');return false;"><@t.page 'site.default_static_config'/></button>
            <button type="button" class="button" onclick="siteDefaultConfig${id!}();return false;"><@t.page 'site.default_dynamic_config'/></button>
        </p>
        <dl class="nowrap">
            <dt><@t.page 'site.dynamic_path'/>:</dt>
            <dd>
                <input class="required" name="dynamicPath" type="text" maxlength="255" size="60" value="${(a.dynamicPath)!}"/>
                <span class="info"><@t.page 'site.site_path.description'/></span>
            </dd>
        </dl>
        <dl class="nowrap">
            <dt><@t.page 'site.site_path'/>:</dt>
            <dd>
                <input name="sitePath" type="text" maxlength="255" size="60" value="${(a.sitePath)!}"/>
                <label><input name="useSsi" type="checkbox"<#if a?has_content&&a.useSsi> checked="checked"</#if>/><@t.page 'site.enable_ssi'/></label>
                <span class="info"><@t.page 'site.dynamic_path.description'/></span>
                <span class="info"><@t.page 'site.enable_ssi.description'/></span>
            </dd>
        </dl>
        <#if !a?has_content>
            <fieldset>
                <legend><@t.page 'site.init'/></legend>
                <dl class="nowrap">
                    <dt><@t.page 'domain'/>:</dt>
                    <dd>
                        <input class="<#if !parent?has_content>required </#if>domain" remote="sysDomain/virify" name="domain" data-msg-remote="<@t.message 'verify.hasExist.domain'/>" type="text" maxlength="50" size="20" value=""/>
                        <label><input name="wild" type="checkbox"/><@t.page 'domain.wild'/></label>
                        <#if !parent?has_content><label><input name="multiple" type="checkbox"/><@t.page 'domain.multiple'/></label></#if>
                        <span class="info"><@t.page 'domain.description'/></span>
                    </dd>
                </dl>
                <dl class="nowrap">
                    <dt><@t.page 'role'/>:</dt>
                    <dd>
                        <input class="required" name="roleName" type="text" maxlength="50" size="20" value="<@t.page 'site.default_role'/>"/>
                    </dd>
                </dl>
                <dl class="nowrap">
                    <dt><@t.page 'dept'/>:</dt>
                    <dd>
                        <input class="required" name="deptName" type="text" maxlength="50" size="20" value="<@t.page 'site.default_dept'/>"/>
                    </dd>
                </dl>
                <dl class="nowrap">
                    <dt><@t.page 'user.username'/>:</dt>
                    <dd>
                        <input class="required" name="userName" type="text" maxlength="45" size="20" value="admin"/>
                    </dd>
                </dl>
                <dl class="nowrap">
                    <dt><@t.page 'password'/>:</dt>
                    <dd>
                        <input class="required" name="password" type="password" escape="true" maxlength="255" size="20" value=""/>
                    </dd>
                </dl>
            </fieldset>
        </#if>
    </div>
</form>